package com.ask.apiLake;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/session")
public class SessionController {
    @PostMapping("/login")
    public String doLogin(HttpSession session) {
        session.setAttribute("dogName", "jack");
        return "set dogName";
    }

    @GetMapping("/getSession")
    public String getSession(HttpSession session) {
        String dogName = (String) session.getAttribute("dogName");
        System.out.println(dogName);
        return "dogName:" + dogName;
    }
}
